package net.lab1024.sa.admin.module.business.research.controller;

import net.lab1024.sa.admin.module.business.research.domain.form.ResearchAddForm;
import net.lab1024.sa.admin.module.business.research.domain.form.ResearchQueryForm;
import net.lab1024.sa.admin.module.business.research.domain.form.ResearchUpdateForm;
import net.lab1024.sa.admin.module.business.research.domain.vo.ResearchVO;
import net.lab1024.sa.admin.module.business.research.service.ResearchService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 科学论文 Controller
 *
 * @Author KeissCake
 * @Date 2024-09-18 21:41:14
 * @Copyright 暂无
 */

@RestController
@Tag(name = "科学论文")
public class ResearchController {

    @Resource
    private ResearchService researchService;

    @Operation(summary = "分页查询 @author KeissCake")
    @PostMapping("/research/queryPage")
    @SaCheckPermission("research:query")
    public ResponseDTO<PageResult<ResearchVO>> queryPage(@RequestBody @Valid ResearchQueryForm queryForm) {
        return ResponseDTO.ok(researchService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author KeissCake")
    @PostMapping("/research/add")
    @SaCheckPermission("research:add")
    public ResponseDTO<String> add(@RequestBody @Valid ResearchAddForm addForm) {
        return researchService.add(addForm);
    }

    @Operation(summary = "更新 @author KeissCake")
    @PostMapping("/research/update")
    @SaCheckPermission("research:update")
    public ResponseDTO<String> update(@RequestBody @Valid ResearchUpdateForm updateForm) {
        return researchService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author KeissCake")
    @PostMapping("/research/batchDelete")
    @SaCheckPermission("research:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return researchService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author KeissCake")
    @GetMapping("/research/delete/{researchId}")
    @SaCheckPermission("research:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer researchId) {
        return researchService.delete(researchId);
    }
}
